<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function isHasOwnProperty(obj, propName, newValue) {
        if (obj.hasOwnProperty(propName)) {
          // 如果属性存在，则更新其值
          obj[propName] = newValue;
        } else {
          // 如果属性不存在，则添加属性并设置其值
          obj[propName] = newValue;
        }
      }

      const obj = { name: "张三", age: 18 };
      isHasOwnProperty(obj, "name", "hyt");
      isHasOwnProperty(obj, "gender", "女");
      console.log(obj); 
    </script>
  </body>
</html>
    </script>
  </body>
</html>
